package collection_;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @Author 小闽
 * @Date 2024/10/21 22:44
 * @PackageName: collection_
 * @ClassName: Collection_for
 * @Description: 增强型for循环
 * @Version 1.0
 */
public class Collection_for {
    @SuppressWarnings("all")
    public static void main(String[] args) {
        Collection col = new ArrayList();
        col.add(new Book("三国演义","罗贯中",10.1));
        col.add(new Book("小李飞刀","古龙",5.1));
        col.add(new Book("红楼梦","曹雪芹",34.6));

        // 使用增强for, 在Collection集合
        for (Object object : col) {
            System.out.println("object=" + object);
        }
        // 增强for循环可以在数组中使用
        int[] arr = {10,20,30,40,50};
        for(int i : arr){
            System.out.println("i=" + i);
        }

    }
}
